using MallSystembackend.Api.Repository;
using MallSystembackend.Api.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MallSystembackend.Api.ParamModel;
using System.Linq;
namespace MallSystembackend.Api.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class ParamtersOneController : ControllerBase
    {
        public IRepository<ParametersOne> _parametersOne;
        public readonly IConfiguration _configuration;

        public ParamtersOneController(IRepository<ParametersOne> parametersOne,
        IConfiguration configuration)
        {
            _configuration = configuration;
            _parametersOne = parametersOne;
        }
        //添加参数整合，供购物车使用
        [HttpPost]
        public ActionResult AddOne(ParamParametersOne model)
        {
            var ParOne = new ParametersOne
            {
                skuId = model.skuId,
                ParameterValuesId = model.ParameterValuesId,
                ShoppingTrolleyId = model.ShoppingTrolleyId,
                OrderFormId = model.OrderFormId
            };
            _parametersOne.Insert(ParOne);
            return Ok(new
            {
                Code = 1000,
                Data = ParOne,
                Msg = "添加成功"
            });
        }
    }
}